package cn.bklovezz.yixiantong.ram.swagger;

import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
@Profile("dev")
public class RamUserManageSwaggerConfig {
  @Bean
  public Docket coreUserManageApiConfig(){
    return new Docket(DocumentationType.SWAGGER_2)
            .apiInfo(userManageApiInfo())
            .groupName("userManageApi")
            .select()
            //只显示admin下面的路径
            .paths(Predicates.and(PathSelectors.regex("/api/ram/admin/.*")))
            .build();
  }

  public ApiInfo userManageApiInfo() {
    return new ApiInfoBuilder()
            .title("用户管理服务文档")
            .description("Api 接口文档描述")
            .version("1.0")
            .contact(
                    new Contact(
                            "JackZhangzhang",
                            "xxxxx.cn",
                            "826709675@qq.com"
                    )
            )
            .build();
  }
}
